More Forms

 

Goals

Directions

  1. Log on to the NT workstation and copy your form1.html file
      1. Get the html file from the Form 1 lab. If this is unavailable, go to http://cs.wheatonma.edu/universal/javascript/forms/example.html and view source.
  2. Modify your form to verify input
    1. Make the following modifications to your form:
      1. Give your form a name of mailform by entering NAME="mailform" in the <FORM> tag.
      2. Remove the attribute Value="Your Name Here" from the text field name in the form.
      3. Add a text field to your form that asks for an email address. Name this field email.
    2. You’ll want to check that the name and message fields are filled in and that the email field contains a valid email address. In order to do this, you will need to:
      1. Add the functions isReady(), isFilled(), and isEmail() that we looked at yesterday to the head of your document (These are available from the url you have opened in Netscape).
      2. Add the onSubmit event handler to the <FORM> tag.
    3. Notice that you’ll need to change some of the field names in isReady() so that they correspond to the form in this document rather than the one from the in-class demo.
    4. Once you think you have this working, preview your form and see if it works.
    5. Remember that you can check your email using telnet.
  3. Add something special for your friends
    1. Add an if( ) statement to your isReady() function that has the following effect:
      1. It should check the email address to see if your pal’s e-mail addy appears in the address (using the indexOf() method).
      2. If it does appear in the email address, then display an alert box with the message "Hi there buddy…how ya been?"
    2. The appropriate place to add this is just before the line return true;
  4. When you have finished this
    1. Call the instructor or TA over to take a look at your work.
    2. Finally, LOGOUT OF THE MACHINE!!!